package com.example.demo.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auto")
@Api(tags = "2、定时任务管理")
@ApiSupport(author = "罗海林", order = 2)
@EnableScheduling
@Validated
@Slf4j
@RequiredArgsConstructor
public class AutoController {

    //private final ScheduleConfig scheduleTask;

    /*@PostMapping("/test1")
    @Async("sendEmailAsync")
    @Scheduled(fixedDelay = 1000)
    public void test1() {
        System.out.println("第一个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
        System.out.println();
    }

    @PostMapping("/test2")
    @Async("sendEmailAsync")
    @Scheduled(fixedDelay = 5000)
    public void test2() {
        System.out.println("第二个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
        System.out.println();
    }*/

    /*@PostMapping("/updateCron")
    public String updateCron(String cron) {
        log.info("更新 cron 表达式为：{}", cron);
        scheduleTask.setCron(cron);
        return "Cron 表达式更新成功！";
    }*/

}
